home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / MISC.H < prev    next >
C/C++ Source or Header  |  1992-08-12  |  4KB  |  125 lines

  1. //
  2. //
  3. // Copyright (C) 1991 Texas Instruments Incorporated.
  4. //
  5. // Permission is granted to any individual or institution to use, copy, modify,
  6. // and distribute this software, provided that this complete copyright and
  7. // permission notice is maintained, intact, in all copies and supporting
  8. // documentation.
  9. //
  10. // Texas Instruments Incorporated provides this software "as is" without
  11. // express or implied warranty.
  12. //
  13. // This file  contains  useful definitions,  macros, and constants used through
  14. // out most header and source files.
  15. //
  16. // Updated: JAM 08/10/92 -- removed DOS definitions/specifics
  17. // Updated: JAM 08/11/92 -- added BITS definition
  18. // Updated: JAM 08/11/92 -- added <stdio.h> for printf() during error handling
  19. // Updated: JAM 08/12/92 -- made to use <limits.h> and <float.h> instead of
  20. //                          <values.h> for increased standards compliance
  21. //                          (and to fix a BC++ bug with MAXDOUBLE)
  22.  
  23. #ifndef MISCELANEOUSH                // If no miscelaneous header
  24. #define MISCELANEOUSH
  25.  
  26. #include <limits.h>        // platform specific constants
  27. #include <float.h>        // platform specific constants
  28. #include <values.h>        // platform specific constants (deprecated)
  29. #undef MAXDOUBLE  //## temporary hack for BC++ bug until compiled, then fix
  30. #define MAXDOUBLE DBL_MAX
  31. #include <stdio.h>        // because temporarily using printf/abort for errors
  32. #include <stdlib.h>        // because temporarily using printf/abort for errors
  33.  
  34. #ifndef BITS   // at least BC++'s <value.h> didn't have it
  35. #define BITS(type) (CHAR_BIT*(int)sizeof(type))
  36. #endif
  37.  
  38. #ifndef DEFSH
  39. #include <defs.h>                // Include the defs header
  40. #endif
  41.  
  42. #ifndef INVALID                    // Define INVALID for curpos
  43. #define INVALID (-1)
  44. #endif
  45.  
  46. #ifndef END_OF_STRING                // If END_OF_STRING not defined
  47. #define END_OF_STRING (0)
  48. #endif
  49.  
  50. #ifndef NEWLINE                    // If Newline char not defined
  51. #define NEWLINE '\n'
  52. #endif
  53.  
  54. #ifndef SENSITIVE                // If case flags not defined
  55. #define SENSITIVE TRUE
  56. #define INSENSITIVE FALSE
  57. #endif
  58.  
  59. #ifndef NUMBER_STATES
  60. #define NUMBER_STATES
  61. enum N_status { N_OK, N_MINUS_INFINITY, N_PLUS_INFINITY, N_OVERFLOW,
  62.         N_UNDERFLOW, N_NO_CONVERSION, N_DIVIDE_BY_ZERO };
  63. #endif
  64.  
  65. // use of these deprecated in favor of standard <limits.h> macros
  66. #undef MINSHORT
  67. #undef MININT
  68. #undef MINLONG
  69. #undef MAXSHORT
  70. #undef MAXINT
  71. #undef MAXLONG
  72. #define MINSHORT SHRT_MIN
  73. #define MININT INT_MIN
  74. #define MINLONG LONG_MIN
  75. #define MAXSHORT SHRT_MAX
  76. #define MAXINT INT_MAX
  77. #define MAXLONG LONG_MAX
  78.  
  79. /*
  80.   In values.h
  81. #define MAXDOUBLE    1.79769313486231470e+308
  82. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  83. #define MINDOUBLE    4.94065645841246544e-324
  84. #define MINFLOAT    ((float)1.40129846432481707e-45)
  85. #define DMINEXP    (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  86. #define FMINEXP    (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  87. #define    _IEEE        1
  88. #define _DEXPLEN    11
  89. #define _HIDDENBIT    1
  90. */
  91.  
  92. #ifndef ABS
  93. #define ABS(x) ((x >= 0) ? (x) : (-x))
  94. #endif
  95.  
  96. // even --  Determine if long integer is odd of even
  97. // Input:   long integer
  98. // Output:  Boolean TRUE/FALSE
  99.  
  100. inline Boolean even (long n) {
  101.   return ((n & 1) ? FALSE : TRUE);
  102. }
  103.  
  104. // odd --  Determine if long integer is odd of even
  105. // Input:  long integer
  106. // Output: Boolean TRUE/FALSE
  107.  
  108. inline Boolean odd (long n) {
  109.   return ((n & 1) ? TRUE : FALSE);
  110. }
  111.  
  112. // The "#pragma defmacro" is a COOL extension to the standard  ANSI C processor
  113. // that allows  a programmer to  define macro  extensions to the  language. All
  114. // COOL  macros   have  been  incorporated  into  the preprocessor   itself  to
  115. // facilitate extra speed and efficiency. User defined  extensions are searched
  116. // for on the include file path.
  117.  
  118. #pragma defmacro MACRO "macro" delimiter=} recursive
  119. #pragma defmacro template "template" delimiter=}
  120. #pragma defmacro DECLARE "declare" delimiter=> recursive lines
  121. #pragma defmacro IMPLEMENT "implement" delimiter=> recursive lines
  122.  
  123. #endif MISCELANEOUSH                // End #ifdef
  124.  
  125.